package com.xxl.job.executor.util;

import com.alibaba.cloudapi.sdk.constant.SdkConstant;
import com.alibaba.cloudapi.sdk.enums.HttpMethod;
import com.alibaba.cloudapi.sdk.enums.ParamPosition;
import com.alibaba.cloudapi.sdk.enums.Scheme;
import com.alibaba.cloudapi.sdk.model.ApiRequest;
import com.alibaba.cloudapi.sdk.model.ApiResponse;
import com.alibaba.cloudapi.sdk.model.HttpClientBuilderParams;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @author dingfeng
 * @version 1.0
 * @DEC
 * @date 2022/3/4 11:34
 */
@Component
@Slf4j
public class AliyunApiClientUtil {

    @Autowired
    private HttpApiClient httpApiClient;


    public ApiResponse query(String path, String method, Map<String, String> params) {
        httpApiClient.init(getHttpClientBuilderParams());
        ApiResponse apiResponse = httpApiClient.query(
                "/data/graph/tianqi", "get", null);
        return apiResponse;
    }

    public ApiResponse query(String path) {
       return query(path,null,null);
    }


    public HttpClientBuilderParams getHttpClientBuilderParams(){
        HttpClientBuilderParams httpParam = new HttpClientBuilderParams();
        httpParam.setAppKey("203811500");
        httpParam.setAppSecret("zmlqdt6lu3g02kk2fzizrar6cd2cs9wg");
        httpParam.setHost("06b8a04ab325450a9af47c2bbf41ad5e-cn-shenzhen.alicloudapi.com");
        httpParam.setScheme(Scheme.HTTP);
        return httpParam;
    }

}
